<?php
$document =& JFactory::getDocument();
//Insert Javascription into Page
//Joomla da include san mootools.js roi
//$document->addScript(JURI::root(false).'administrator/components/com_jbschedule/js/mootools.v1.11.js' );
$document->addScript(JURI::base().'components/com_jbschedule/media/js/nogray_time_picker_min.js' );
$document->addScript(JURI::base().'components/com_jbschedule/media/js/nogray_time_picker.js' );
$document->addScript(JURI::base().'components/com_jbschedule/media/js/301a.js' );
$document->addStyleSheet(JURI::base().'components/com_jbschedule/media/css/default.css');
//Insert Javascription into Page
$document->addScript(JURI::root(false).'administrator/components/com_jbschedule/media/js/functions.js' );
?>
<?php JHTML::_('behavior.formvalidation'); ?>
<?php JHTML::_('behavior.calendar');?>

<script language="javascript">
	window.addEvent("domready", function(){
		var tp  = new TimePicker('start_time_picker', 'start_time', 'start_time_toggler',{format24:true},{imagesPath:'<?=JURI::root(false)?>administrator/components/com_jbschedule/media/images/img_clock'});
		var tp1 = new TimePicker('end_time_picker', 'end_time', 'end_time_toggler',{format24:true},{imagesPath:'<?=JURI::root(false)?>administrator/components/com_jbschedule/media/images/img_clock'});
	});
	window.onload = function(){
		//alert('thoong tin');
		onloadRecur(<?=$this->events->recur_type?>);
		editChangeColor(<?=$this->events->use_master_color?>);
		disable_enable_time_event();
		onloadRecurType(<?=$this->events->recur_type?>);
	}
	
	window.onDomReady(function() {
		document.formvalidator.setHandler('whitespace', function(value) {
			regex=/^\s+$/;
			return !regex.test(value);
		})
		document.formvalidator.setHandler('positive', function(value) {
			regex=/^(0?[1-9][0-9]*)$/;
			return regex.test(value);
		})
		document.formvalidator.setHandler('positive31', function(value) {
			regex=/^(0?[1-9]|[1-2][0-9]|[3][0-1])$/;
			return regex.test(value);
		})
		document.formvalidator.setHandler('vdate', function(value) {
			regex=/^\d{4}\-\d{2}\-\d{2}$/;
			return regex.test(value);
		})
	})
	
</script>
<script type="text/javascript"><!--
function myValidate(form) {
	var error = '';
	var ok = true;
	for(i=0; i<form.elements.length; i++){
		if (! document.formvalidator.validate(form.elements[i])) {
			switch(form.elements[i].name){
				case 'subject':
						error += '<?=JText::_('SUBJECT IS REQUIRED') ?>\n';
						ok = false;
					break;
				case 'content':
						error += '<?=JText::_('CONTENT IS REQUIRED') ?>\n';
						ok = false;
					break;
				case 'start_date':
						error += '<?=JText::_('START DATE IS REQUIRED') ?>\n';
						ok = false;
					break;	
				case 'end_date':
						error += '<?=JText::_('END DATE IS REQUIRED') ?>\n';
						ok = false;
					break;	
				case 'recur_daily_day':
						if(document.getElementById('daily').checked){
							error += '<?=JText::_('RECUR DAILY DAY IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
				case 'recur_weekly_week':
						if(document.getElementById('weekly').checked){
							error += '<?=JText::_('RECUR WEEKLY WEEK IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
				case 'recur_monthly_month_day_x':
						if(document.getElementById('r_recur_monthly_option_day').checked && document.getElementById('monthly').checked){
							error += '<?=JText::_('NUMBER DAY IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
				case 'recur_monthly_month_day_y':
						if(document.getElementById('r_recur_monthly_option_day').checked && document.getElementById('monthly').checked){
							error += '<?=JText::_('NUMBER MONTHLY IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
				case 'recur_monthly_month_date_n':
						if(document.getElementById('r_recur_monthly_option_the').checked && document.getElementById('monthly').checked){
							error += '<?=JText::_('NUMBER MONTHLY IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
				case 'recur_yearly_year_month_y':
						if(document.getElementById('r_recur_yearly_option_every').checked && document.getElementById('yearly').checked){
							error += '<?=JText::_('NUMBER DAY IS REQUIRED') ?>\n';
							ok = false;
						}
					break;
			}
		}
	}
	if(error != '')
		alert(error);

	if(ok)
		form.check.value='<?php echo JUtility::getToken(); ?>';//send token
	return ok;
}

//Override the base function in folder: include/js/joomla.javascript.js
function submitbutton(pressbutton) {
	if(pressbutton != 'cancel'){
		if(myValidate(document.adminForm))
			submitform(pressbutton);
			selectAllOptions('tableOne');
	}else{
		submitform(pressbutton)
	}
}
function changeRecurType(e){
	var vid = e.id;
	switch(vid){
		case 'daily':
			document.getElementById('dailyTab').style.display = 'block';
			document.getElementById('weeklyTab').style.display = 'none';
			document.getElementById('monthlyTab').style.display = 'none';
			document.getElementById('yearlyTab').style.display = 'none';
  			break;
		case 'weekly':
			document.getElementById('dailyTab').style.display = 'none';
			document.getElementById('weeklyTab').style.display = 'block';
			document.getElementById('monthlyTab').style.display = 'none';
			document.getElementById('yearlyTab').style.display = 'none';
	    break;
	    case 'monthly':
			document.getElementById('dailyTab').style.display = 'none';
			document.getElementById('weeklyTab').style.display = 'none';
			document.getElementById('monthlyTab').style.display = 'block';
			document.getElementById('yearlyTab').style.display = 'none';
	    break;
	    case 'yearly':
			document.getElementById('dailyTab').style.display = 'none';
			document.getElementById('weeklyTab').style.display = 'none';
			document.getElementById('monthlyTab').style.display = 'none';
			document.getElementById('yearlyTab').style.display = 'block';
	    break;
	}
}
//on load recur tab
function onloadRecur(i){
	switch(i){
		case 0:
			//Tab daily is selected
			document.getElementById('daily').disabled = false;
			document.getElementById('weekly').disabled = false;
			document.getElementById('monthly').disabled = false;
			document.getElementById('yearly').disabled = false;
			document.getElementById('recur_type').checked = false;
//			alert('truong hop 0');
  			break;
		case 1:
			//Tab daily is selected
			getNameTab('daily');
  			break;
		case 2:
			//Tab weekly is selected
			getNameTab('weekly');
	    break;
	    case 3:
	    	//Tab monthly is selected
	    	getNameTab('monthly');
	    break;
	    case 4:
	    	//Tab yearly is selected
	    	getNameTab('yearly');
	    break;
	}
}
function changeColor(){
	if (document.getElementById('use_master_color').value == 0){
		//alert('NO');
		document.getElementById('color').disabled=false;
		document.getElementById('valueColor').disabled=false;
		document.getElementById('colorpicker').disabled =false;
	}else if (document.getElementById('use_master_color').value == 1){
		//alert('YES');
		document.getElementById('color').disabled=true;
		document.getElementById('valueColor').disabled=true;
		document.getElementById('colorpicker').disabled =true;
	}
}
// edit change color
function editChangeColor(i){
	if (i == 0){
		//alert('NO');
		document.getElementById('color').disabled=false;
		document.getElementById('valueColor').disabled=false;
		document.getElementById('colorpicker').disabled =false;
	}else if (i == 1){
		//alert('YES');
		document.getElementById('color').disabled=true;
		document.getElementById('valueColor').disabled=true;
		document.getElementById('colorpicker').disabled =true;
	}
}
// function enable or disable element time event
function disable_enable_time_event(){
	if (document.getElementById('is_allday_event').checked == true){
		document.getElementById('is_allday_event').value = 1;
		document.getElementById('start_time').disabled = true;
		document.getElementById('start_time_toggler').disabled = true;
		document.getElementById('end_time').disabled = true;
		document.getElementById('end_time_toggler').disabled = true;
	}else if (document.getElementById('is_allday_event').checked == false){
		document.getElementById('is_allday_event').value = 0;
		document.getElementById('start_time').disabled = false;
		document.getElementById('start_time_toggler').disabled = false;
		document.getElementById('end_time').disabled = false;
		document.getElementById('end_time_toggler').disabled = false;
	}
}
//function enable or disable recur_type
function disable_enable_recur_type(){	
	if (document.getElementById('recur_type').checked == true){
//		alert('enable ');
		var id = '<? echo $this->events->id; ?>';
		if (id == 0){
//			alert('NEW');
			document.getElementById('daily').disabled = false;
			document.getElementById('weekly').disabled = false;
			document.getElementById('monthly').disabled = false;
			document.getElementById('yearly').disabled = false;
		}else if (id > 0){
//			alert('EDIT');
			var recur = '<? echo $this->events->recur_type; ?>';
			switch(recur){
				case '0':
					enableTab();										
					break;
				case '1':
					getNameTab('daily');
					enableTab();
					break;
				case '2':
					getNameTab('weekly');
					enableTab();
					break;
				case '3':
					getNameTab('monthly');
					enableTab();
					break;
				case '4':
					getNameTab('yearly');
					enableTab();
					break;
			}
		}
	}else if (document.getElementById('recur_type').checked == false){
		//disable tab daily
//		alert('disable ');
		disableTab();
				
	}
}
// onload recutype
function onloadRecurType(i){
	var id = '<? echo $this->events->id; ?>';
	var re = '<? echo $this->events->recur_type?>';
	//alert (id);
	if (id == 0 || re == 0 ){
		document.getElementById('recur_type').checked = false;
		disableTab();
	}else if (id > 0){
		document.getElementById('recur_type').checked = true;
	}
}
//define function name tab
function getNameTab(nameTab){
	document.getElementById(nameTab).checked = 1;
	document.getElementById(nameTab+'Tab').style.display = 'block';
}
//enabel Tab
function enableTab(){
	document.getElementById('daily').disabled 	= false;
	document.getElementById('weekly').disabled 	= false;
	document.getElementById('monthly').disabled = false;
	document.getElementById('yearly').disabled 	= false;
}
//disable tab
function disableTab(){
	document.getElementById('recur_type').value 		= 0;
	document.getElementById('daily').checked 			= false;
	document.getElementById('dailyTab').style.display 	= 'none';
	document.getElementById('weekly').checked 			= false;
	document.getElementById('weeklyTab').style.display 	= 'none';
	document.getElementById('monthly').checked 			= false;
	document.getElementById('monthlyTab').style.display = 'none';
	document.getElementById('yearly').checked 			= false;
	document.getElementById('yearlyTab').style.display 	= 'none';
	document.getElementById('daily').disabled 			= true;
	document.getElementById('weekly').disabled 			= true;
	document.getElementById('monthly').disabled 		= true;
	document.getElementById('yearly').disabled 			= true;
}
--></script>
<form action="index.php" method="post" name="adminForm" id="adminForm" class="form-validate"  onsubmit="selectAllOptions('tableOne')">
<input type="hidden" name="check" value="post"/>
<div class="col100">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'EVENT INFOMATION' ); ?></legend>
		<table class="admintable">
		<tr>
			<td width="200" align="right" class="key">
				<label>
					<?php echo JText::_('EVENTS TYPE'); ?>:
				</label>
			</td>
			<td>
				<?php echo $this->fillDataEventtype;?>
			</td>
		</tr>
		<tr>
			<td align="right" class="key">
				<label for="subject">
					<?php echo JText::_( 'SUBJECT' ); ?>:
				</label>
			</td>
			<td>
				<input class="text_area required validate-whitespace" type="text" name="subject" id="subject" style="width: 150px;" maxlength="250" value="<?php echo $this->events->subject;?>"/>
			</td>
		</tr>
		<tr>
			<td align="right" class="key">
				<label for="content">
					<?php echo JText::_( 'CONTENT' ); ?>:
				</label>
			</td>
			<td>
				<textarea class="text_area required" rows="5" name="content" id="content" cols="42"><?php echo $this->events->content;?></textarea>
			</td>
		</tr>
		<tr>
			<td align="right" class="key">
				<label>
					<?php echo JText::_( 'ASSETS' ); ?>:
				</label>
			</td>
			<td>
			<?php echo $this->fillAsset;?>
			</td>
		</tr>
		<tr>
			<td align="right" class="key">
				<label>
					<?php echo JText::_( 'COLOR' ); ?>:
				</label>
			</td>
			<td>
				<div id="colorpicker301" class="colorpicker301"></div>
				<input type="text" id="color" name="color" value="<?=$this->events->color?>" size="9" disabled="disabled">&nbsp;
				<input TYPE="text" SIZE="1" id="valueColor" disabled="disabled">
				<input type="button" id="colorpicker" name="colorpicker" disabled="disabled" onclick="showColorGrid3('color','valueColor');" value="...">
			</td>
		</tr>
		<tr>
			<td align="right" class="key">
				<label for="use_master_color">
					<?php echo JText::_( 'USER MASTER COLOR' ); ?>:
				</label>
			</td>
			<td>
				<select name="use_master_color" id="use_master_color" size="1" onchange="changeColor()">
				<?php
					if ($this->events->use_master_color == null){
						echo "<option value=\"1\" selected=\"selected\">".JText::_("YES")."</option>";
						echo "<option value=\"0\" >".JText::_("NO")."</option>";
					}else{
						if ($this->events->use_master_color == 1){
							echo "<option value=\"1\" selected=\"selected\">".JText::_("YES")."</option>";
							echo "<option value=\"0\" >".JText::_("NO")."</option>";
						}
						else if ($this->events->use_master_color == 0){
							echo "<option value=\"1\" >".JText::_("YES")."</option>";
							echo "<option value=\"0\" selected=\"selected\">".JText::_("NO")."</option>";
						}
					}
				?>
				</select>
			</td>
		</tr>
	</table>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'EVENT USERS' ); ?></legend>
		<table class="admintable">
			<tr>
				<td align="right" class="key">
					<label>
						<?php echo JText::_( 'USERS' ); ?>:
					</label>
				</td>
				<td align="left">
					<?php echo $this->htmlRole;?>
				</td>
			</tr>					
		</table>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'EVENT TIME' ); ?></legend>
		<table class="admintable">
			<tr>
				<td align="right" class="key">
					<label for="is_allday_event">
						<?php echo JText::_( 'ALL DAY EVENT' ); ?>
					</label>
				</td>
				<td>
					<input type="checkbox" name="is_allday_event" id="is_allday_event" onclick="disable_enable_time_event()">
				</td>
			</tr>
			<tr>
				<td align="right" class="key">
					<label for="start_date">
						<?php echo JText::_( 'START DATE' ); ?>:
					</label>
				</td>
				<td>
					<input class="text_area required validate-vdate" type="text" name="start_date"
					id="start_date" size="25" maxlength="25"
					value="<?php echo $this->events->start_date;?>" />
					<input type="reset" class="button" id="btnStart" value="..."
					onclick="return showCalendar('start_date','%Y-%m-%d');" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<?=JText::_("AT")?>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="text" name="start_time" id="start_time" value="<?php echo $this->events->start_time;?>" />
					<input type="reset" class="button" id="start_time_toggler" name="start_time_toggler" value="<?=JText::_("OPEN TIME PICKER")?>" style="width: 100px;"/>
					<div id="start_time_picker" class="time_picker_div"></div>
				</td>
			</tr>
			<tr>
				<td align="right" class="key">
					<label for="end_date">
						<?php echo JText::_( 'END DATE' ); ?>:
					</label>
				</td>
				<td>
					<input class="text_area required validate-vdate" type="text" name="end_date"
					id="end_date" size="25" maxlength="25"
					value="<?php echo $this->events->end_date;?>" />
					<input type="reset" class="button" id="btnEnd" value="..."
					onclick="return showCalendar('end_date','%Y-%m-%d');" />
					&nbsp;&nbsp;&nbsp;&nbsp;
					<?=JText::_("AT")?>
					&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="text" name="end_time" id="end_time" value="<?php echo $this->events->end_time;?>"/>
					<input type="reset" class="button" id="end_time_toggler" name="end_time_toggler" value="<?=JText::_("OPEN TIME PICKER")?>" style="width: 100px;"/>
					<div id="end_time_picker" class="time_picker_div"></div>
				</td>
			</tr>
		</table>
	</fieldset>
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'RECURRING TYPE' ); ?></legend>
		<table class="admintable" width="100%">
			<tr>
				<td align="right" class="key">
					<label for="recur_type">
						<?php echo JText::_( 'RECURRING EVENT' ); ?>
					</label>
				</td>
				<td>
					<input type="checkbox" name="recur_type" id="recur_type" onclick="disable_enable_recur_type()">
				</td>
			</tr>
			<tr>
				<td align="right" class="key">
					<div id="tab_option">
						<label for="daily"><?=JText::_("DAILY")?>
						<input type="radio" name="recurTypeOptions" id="daily" value="1" onClick="changeRecurType(this)"></label><br>
						<label for="weekly"><?=JText::_("WEEKLY")?>
						<input type="radio" name="recurTypeOptions" id="weekly" value="2" onClick="changeRecurType(this)"></label><br>
						<label for="monthly"><?=JText::_("MONTHLY")?>
						<input type="radio" name="recurTypeOptions" id="monthly" value="3" onClick="changeRecurType(this)"></label><br>
						<label for="yearly"><?=JText::_("Yearly")?>
						<input type="radio" name="recurTypeOptions" id="yearly" value="4" onClick="changeRecurType(this)"></label><br>
					</div>
				</td>
				<td>
					<div id="tab_wrapper">
						<div class="tab" id="dailyTab">
						<table width="100%" class="jbschedule_form">
							<tr>
								<td>
									<?php
										$check9 = ($this->events->recur_daily_weekday == 0) ? "checked='checked'":"";
									?>
									<input type="radio" id="r_recur_daily_weekday" name="r_recur_daily_weekday" value="0" <?=$check9?>><?=JText::_("EVERY")?> &nbsp;
									<?php
										if ($this->events->id == 0 || $this->events->recur_daily_day == 0){
									?>
									<input class="text_area required validate-positive" type="text" name="recur_daily_day" id="recur_daily_day" style="text-align: center" size="7" value="1">&nbsp;<?=JText::_("DAY")?>
									<?php
										}else{
									?>
									<input class="text_area required validate-positive" type="text" name="recur_daily_day" id="recur_daily_day" style="text-align: center" size="7" value="<?=$this->events->recur_daily_day?>">&nbsp;<?=JText::_("DAY")?>
									<?php		
										}								
									?>									
								</td>
							</tr>
							<tr>
								<td>
								<?php
									$check10 = ($this->events->recur_daily_weekday == 1) ? "checked='checked'":"";
								?>
								<input type="radio" name="r_recur_daily_weekday" value="1" <?=$check10?>><?=JText::_("EVERY WEEKDAY") ?>
								</td>
							</tr>
						</table>
						</div>
						<div class="tab" id="weeklyTab">
						<table width="100%" class="jbschedule_form">
							<tr>
								<td>
								<?php
									if ($this->events->recur_weekly_week == 0 || $this->events->id == 0){
								?>
								&nbsp;<?=JText::_("RECUR EVERY")?>&nbsp;<input id="recur_weekly_week" class="required validate-positive" style="text-align: center" name="recur_weekly_week" size="7" type="text" value="1">&nbsp;<?=JText::_("WEEK")?><?=JText::_("ON")?>						
								<?php										
									}else{
								?>
								&nbsp;<?=JText::_("RECUR EVERY") ?>&nbsp;<input id="recur_weekly_week" class="required validate-positive" style="text-align: center" name="recur_weekly_week" size="7" type="text" value="<?=$this->events->recur_weekly_week ?>">&nbsp;<?=JText::_("WEEK") ?>  <?=JText::_("ON")?>
								<?php
									}
								?>
								</td>
							</tr>
							<tr>
								<td>
								<?php
									function checkIN($i,$ar){
										$ok = false;
										$temp = split('[,]',$ar);
										for ($e=0;$e<count($temp);$e++){
											if ($temp[$e] == $i){
												$ok = true;
											}
										}
										return $ok;
									}
									$arrDay = array(JText::_("MONDAY"),JText::_("TUESDAY"),JText::_("WEDNESDAY"),JText::_("THURSDAY"),JText::_("FRIDAY"),JText::_("SATURDAY"),JText::_("SUNDAY"));
									for($it = 0;$it<count($arrDay);$it++){
										$check5 = checkIN(($it),$this->events->recur_weekly_week_day) ? "checked='checked'": "";
										echo "<input id=\"cb_wd".$it."\" name=\"recur_weekly_week_day[]\" value=".($it)." type=\"checkbox\" ".$check5.">";
										echo "&nbsp;&nbsp;<label for=\"cb_wd".$it."\">".$arrDay[$it]."</label>&nbsp;";
									}
								?>
								</td>
							</tr>
						</table>
						</div>
						<div class="tab" id="monthlyTab">
						<table width="100%" class="jbschedule_form">
							<tr>
								<td>
									<?php
										$check7 = ($this->events->recur_monthly_option == 0) ? "checked='checked'":"";
										list($recur_monthly_month_day_x,$recur_monthly_month_day_y) = split('[,]',$this->events->recur_monthly_month_day);
									?>
									<input type="radio" id="r_recur_monthly_option_day"  name="r_recur_monthly_option" value="0" <?=$check7?>><?=JText::_("DAY") ?> &nbsp;&nbsp;
									<input type="text" class="text_area required validate-positive31" id="recur_monthly_month_day_x" style="text-align: center;" name="recur_monthly_month_day_x" size="7" value="<?=(empty($recur_monthly_month_day_x)?'1':$recur_monthly_month_day_x)?>">&nbsp;<?=JText::_("OF EVERY") ?>
									<input type="text" class="text_area required validate-positive" id="recur_monthly_month_day_y" style="text-align: center;" name="recur_monthly_month_day_y" size="7" value="<?=(empty($recur_monthly_month_day_y)?'1':$recur_monthly_month_day_y)?>">&nbsp;<?=JText::_("MONTH") ?>
								</td>
							</tr>
							<tr>
								<td>
								<?php
									$check8 = ($this->events->recur_monthly_option == 1) ? "checked='checked'":"";
								?>
								<input type="radio" id="r_recur_monthly_option_the" name="r_recur_monthly_option" value="1" <?=$check8?> ><?=JText::_("THE") ?>&nbsp;
								<?php
									list($recur_monthly_month_date_x,$recur_monthly_month_date_y,$recur_monthly_month_date_n) = split('[,]',$this->events->recur_monthly_month_date);
									$arrDX = array(JText::_('FIRST'),JText::_('SECOND'),JText::_('THIRD'),JText::_('FOURTH'),JText::_('LAST'));
									echo "<select name=\"recur_monthly_month_date_x\" style=\"width: 72px;\">";

									for($ik=0;$ik<count($arrDX);$ik++){
										$checkdx = ($ik == $recur_monthly_month_date_x)? "selected='selected'": "";
										echo "<option value=".$ik." ".$checkdx.">".$arrDX[$ik]."</option>";
									}
									echo "</select>";
									echo "&nbsp;";
									$arrDY = array(JText::_('MONDAY'),JText::_('TUESDAY'),JText::_('WEDNESDAY'),JText::_('THURSDAY'),JText::_('FRIDAY'),JText::_('SATURDAY'),JText::_('SUNDAY'));
									echo "<select name=\"recur_monthly_month_date_y\" style=\"width: 80px;\">";
									for($ih=0;$ih<count($arrDY);$ih++){
										$checkdy = ($ih == $recur_monthly_month_date_y)? "selected='selected'": "";
										echo "<option value=".$ih." ".$checkdy.">".$arrDY[$ih]."</option>";
									}
									echo "</select>";
									echo "&nbsp;".JText::_("OF EVERY")."&nbsp;";
								?>
								<input type="text" class="text_area required validate-positive" id="recur_monthly_month_date_n" style="text-align: center" name="recur_monthly_month_date_n" size="7" value="<?=(empty($recur_monthly_month_date_n)?'1':$recur_monthly_month_date_n)?>">&nbsp;<?=JText::_("MONTH") ?>
								</td>
							</tr>
						</table>
						</div>
						<div class="tab" id="yearlyTab">
						<table width="100%" class="jbschedule_form">
							<tr>
								<td>
									<?php
										$recur_yearly_option1 = ($this->events->recur_yearly_option==0)? "checked='checked'" : "";
									?>
										<input type="radio" id="r_recur_yearly_option_every" name="r_recur_yearly_option" value="0" <?=$recur_yearly_option1?>/><?=JText::_("Every") ?> &nbsp;&nbsp;
									<?php
										$dataRecurYearlyYearMonth = $this->events->recur_yearly_year_month;
										list($recur_yearly_year_month_x, $recur_yearly_year_month_y) = split('[,]', $dataRecurYearlyYearMonth);
										$arrT = array(JText::_('JANUARY'),JText::_('FEBRUARY'),JText::_('MARCH'),JText::_('APRIL'),JText::_('MAY'),JText::_('JUNE'),JText::_('JULY'),JText::_('AUGUST'),JText::_('SEPTEMBER'),JText::_('OCTOBER'),JText::_('NOVEMBER'),JText::_('DECEMBER'));
										echo "<select name=\"recur_yearly_year_month_x\" style=\"width: 80px;\">";
										for($i=0;$i<count($arrT);$i++){
											$check1 = ($recur_yearly_year_month_x == $i) ? "selected='selected'": "";
											echo "<option value=".$i." ".$check1.">".$arrT[$i]."</option>";
										}
										echo "</select>";
									?>
								&nbsp;<?=JText::_("DAY") ?>
								<input type="text" class="text_area required validate-positive" style="text-align: center" id="recur_yearly_year_month_y" name="recur_yearly_year_month_y" size="7" value="<?=empty($recur_yearly_year_month_y) ? '1' : $recur_yearly_year_month_y?>">
								</td>
							</tr>
							<tr>
								<td>
								<?php
									$recur_yearly_option2 = ($this->events->recur_yearly_option==1)? "checked='checked'": "";
								?>
								<input type="radio" id="r_recur_yearly_option_the" name="r_recur_yearly_option" value="1" <?=$recur_yearly_option2?>/><?=JText::_("THE") ?> &nbsp;&nbsp;
								<?php
									$dataRecurYearlyYearMonths = $this->events->recur_yearly_year_months;
									list($recur_yearly_year_months_x, $recur_yearly_year_months_y,$recur_yearly_year_months_n) = split('[,]', $dataRecurYearlyYearMonths);
									$arrMX = array(JText::_('FIRST'),JText::_('SECOND'),JText::_('THIRD'),JText::_('FOURTH'),JText::_('LAST'));
									echo "<select name=\"recur_yearly_year_months_x\" style=\"width: 65px;\">";
									for ($imx=0;$imx<count($arrMX);$imx++){
										$check2 = ($imx == $recur_yearly_year_months_x)? "selected='selected'": "";
										echo "<option value=".$imx." ".$check2.">".$arrMX[$imx]."</option>";
									}
									echo "</select>";
									echo "&nbsp;&nbsp;";
									$arrMY = array(JText::_('MONDAY'),JText::_('TUESDAY'),JText::_('WEDNESDAY'),JText::_('THURSDAY'),JText::_('FRIDAY'),JText::_('SATURDAY'),JText::_('SUNDAY'));
									echo "<select name=\"recur_yearly_year_months_y\" style=\"width: 80px;\">";
									for ($imy=0;$imy<count($arrMY);$imy++){
										$check3 = ($imy == $recur_yearly_year_months_y)? "selected='selected'": "";
										echo "<option value=".$imy." ".$check3.">".$arrMY[$imy]."</option>";
									}
									echo "</select>";
									echo "&nbsp; ".JText::_('OF')." ";
									echo "<select name=\"recur_yearly_year_months_n\" style=\"width: 80px;\">";
									for($i=0;$i<count($arrT);$i++){
										$check4 = ($recur_yearly_year_months_n == $i) ? "selected='selected'": "";
										echo "<option value=".$i." ".$check4.">".$arrT[$i]."</option>";
									}
									echo "</select>";
								?>
								</td>
							</tr>
						</table>
						</div>
					</div>
				</td>
			</tr>
		</table>
	</fieldset>
</div>
<div class="clr"></div>
<input type="hidden" name="option" value="com_jbschedule" />
<input type="hidden" name="id" value="<?php echo $this->events->id;?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="events" />
</form>